import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'
import { User } from '@prisma/client'
import { Auth } from '../auth/auth.decorator'
import { CurrentUser } from './../auth/current-user.decorator'
import { CreateSoftDto } from './dto/create-soft.dto'
import { UpdateSoftDto } from './dto/update-soft.dto'
import { SoftService } from './soft.service'

@Controller('soft')
export class SoftController {
	constructor(private readonly soft: SoftService) {}

	@Post()
	@Auth()
	create(@Body() dto: CreateSoftDto, @CurrentUser() user: User) {
		return this.soft.create(dto, user)
	}

	@Get()
	findAll(@Query('page') page: number, @Query('limit') limit: number) {
		return this.soft.findAll(+page, +limit)
	}

	@Get(':id')
	findOne(@Param('id') id: string) {
		return this.soft.findOne(+id)
	}

	@Patch(':id')
	@Auth()
	update(@Param('id') id: string, @Body() updateSoftDto: UpdateSoftDto) {
		return this.soft.update(+id, updateSoftDto)
	}

	@Delete(':id')
	@Auth()
	remove(@Param('id') id: string) {
		return this.soft.remove(+id)
	}
}
